package com.calm.editor.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.calm.editor.api.CacheHandler;
import com.calm.editor.api.CacheService;
@Service
public class SimpleCacheServiceImpl<R> implements CacheService<R> {
	private Map<Object,R> cache = new HashMap<Object,R>();
	public <T> R handler(T para, CacheHandler<T,R> cacheHandler) throws Exception {
		R serializable = cache.get(para);
		if(serializable==null){
			serializable = cacheHandler.handler(para);
			if(serializable!=null){
//				cache.put(para, serializable);
			}
		}
		return serializable;
	}
	
}
